package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.makerspace.domain.MessageDO;
import com.example.makerspace.domain.SingInRecordDO;
import com.example.makerspace.mapper.SingInRecordMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component
public class SingInRecordDAO extends  BaseDAO<SingInRecordDO> {
    @Resource
    private SingInRecordMapper singInRecordMapper;

    private  static  final  String USERNAME="username";

    @PostConstruct
    public void init(){
        this.mapper = singInRecordMapper;
    }

    public List<SingInRecordDO> selectByUserName(String username) {
        QueryWrapper<SingInRecordDO> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        return mapper.selectList(wrapper);
    }

    public void deleteByUsername(String username) {
        mapper.delete(new QueryWrapper<SingInRecordDO>().eq(USERNAME,username));
    }
}
